We give meaning to the first and second laws of thermodynamics in case of mesoscopic out-of-equilibrium systems which are driven by diffusion processes. The notion of the entropy production is analyzed. The role of the Helmholtz extremum principle is contrasted to that of the more familiar entropy extremum principles.